home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekkan Dennou Club 147
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan).7z
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan) (Track 1).bin
/
docs
/
perl
/
mscalar.pl
< prev
next >
Wrap
Perl Script
|
2000-06-25
|
696b
|
45 lines
# タイによるスカラーの監視
package MonScalar;
sub TIESCALAR {
my ($pkg, $name, $value) = @_;
my $obj = { name => $name, value => $value };
bless $obj, $pkg;
$obj;
}
sub FETCH {
my $obj = shift;
print 'Read : $', $obj->{'name'}, " -> $obj->{'value'}\n";
$obj->{'value'};
}
sub STORE {
my ($obj, $new_value) = @_;
print 'Write : $', $obj->{'name'}," <- $new_value\n";
$obj->{'value'} = $new_value;
}
sub DESTROY {
print "DESTORY\n";
}
package main;
$x = 10;
tie $x, 'MonScalar', 'x', $x;
$y = $x;
print "y -> $y\n";
$x = 100;
$z = $x;
print "z -> $z\n";
untie $x;
print "x -> $x\n";
# end of file;